<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta name="Content-Type" content="text/html; charset=UTF-8" />
<title>Module: Sass::Shared</title>
<link rel="stylesheet" href="style.css" tppabs="http://sass-lang.com/docs/yardoc/css/style.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="common.css" tppabs="http://sass-lang.com/docs/yardoc/css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '..';
  if (relpath != '') relpath += '/';
</script>
<script type="text/javascript" charset="utf-8" src="jquery.js" tppabs="http://sass-lang.com/docs/yardoc/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="app.js" tppabs="http://sass-lang.com/docs/yardoc/js/app.js"></script>

  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html" tppabs="http://sass-lang.com/docs/yardoc/_index.html">Index (S)</a> &raquo; 
    <span class='title'><a href="Sass-1.html" tppabs="http://sass-lang.com/docs/yardoc/Sass.html" title="Sass (module)">Sass</a></span>
     &raquo; 
    <span class="title">Shared</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="javascript:if(confirm(%27http://sass-lang.com/docs/yardoc/Sass/.  \n\nThis file was not retrieved by Teleport Pro, because the server reports that this file cannot be found.  \n\nDo you want to open it from the server?%27))window.location=%27http://sass-lang.com/docs/yardoc/Sass/.%27" tppabs="http://sass-lang.com/docs/yardoc/Sass/." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  <a id="class_list_link" href="#">Class List</a>
  <a id="method_list_link" href="#">Method List</a>
  <a id ="file_list_link" href="#">File List</a>
</div>

      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Module: Sass::Shared 
  
  
</h1>

<dl class="box">
  
  
    
      <dt class="r1">Extends:</dt>
      <dd class="r1"><a href="" title="Sass::Shared (module)">Shared</a></dd>
      
    
  
    
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">/var/www/sass-pages/.sass/lib/sass/shared.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>This module contains functionality that&#8217;s shared between Haml and Sass.</p>

  </div>
</div>
<div class="tags">
  
</div>


  <h2>Instance Method Summary</h2>

  <ul class="summary">
    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#balance-instance_method" title="#balance (instance method)">- ((String, String)) <strong>balance</strong>(scanner, start, finish, count = 0) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Moves a scanner through a balanced pair of characters.</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#handle_interpolation-instance_method" title="#handle_interpolation (instance method)">- (String) <strong>handle_interpolation</strong>(str) {|scan| ... }</a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Scans through a string looking for the interoplation-opening <code>#{</code> and, when it&#8217;s found, yields the scanner to the calling code so it can handle it properly.

The scanner will have any backslashes immediately in front of the <code>#{</code> as the second capture group (<code>scan[2]</code>), and the text prior to that as the first (<code>scan[1]</code>)..</span>
  
</li>

    
      <li class="public ">
  <span class="summary_signature">
    
      <a href="#human_indentation-instance_method" title="#human_indentation (instance method)">- (String) <strong>human_indentation</strong>(indentation, was = false) </a>
    

    
  </span>
  
  
  
  
  

  
    <span class="summary_desc">Formats a string for use in error messages about indentation.</span>
  
</li>

    
  </ul>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="balance-instance_method">
  
    - (<tt>(String, String)</tt>) <strong>balance</strong>(scanner, start, finish, count = 0) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Moves a scanner through a balanced pair of characters. For example:</p>

<pre class="code">Foo (Bar (Baz bang) bop) (Bang (bop bip))
^                       ^
from                    to</pre>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>StringScanner</tt>)</span>
      
      
        <span class='name'>scanner</span>
      
      
      
        &mdash;
        The string scanner to move
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Character</tt>)</span>
      
      
        <span class='name'>start</span>
      
      
      
        &mdash;
        The character opening the balanced pair. A <code>Fixnum</code> in 1.8, a <code>String</code> in 1.9
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Character</tt>)</span>
      
      
        <span class='name'>finish</span>
      
      
      
        &mdash;
        The character closing the balanced pair. A <code>Fixnum</code> in 1.8, a <code>String</code> in 1.9
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Fixnum</tt>)</span>
      
      
        <span class='name'>count</span>
      
      
        <em class="default">(defaults to: <tt>0</tt>)</em>
      
      
        &mdash;
        The number of opening characters matched before calling this method
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>(String, String)</tt>)</span>
      
      
      
      
        &mdash;
        The string matched within the balanced pair and the rest of the string. <code>[&quot;Foo (Bar (Baz bang) bop)&quot;, &quot; (Bang (bop bip))&quot;]</code> in the example above.
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


39
40
41
42
43
44
45
46
47
48
49</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/shared.rb', line 39</span>

def balance(scanner, start, finish, count = 0)
  str = ''
  scanner = Sass::Util::MultibyteStringScanner.new(scanner) unless scanner.is_a? StringScanner
  regexp = Regexp.new("(.*?)[\\#{start.chr}\\#{finish.chr}]", Regexp::MULTILINE)
  while scanner.scan(regexp)
    str << scanner.matched
    count += 1 if scanner.matched[-1] == start
    count -= 1 if scanner.matched[-1] == finish
    return [str.strip, scanner.rest] if count == 0
  end
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="handle_interpolation-instance_method">
  
    - (<tt>String</tt>) <strong>handle_interpolation</strong>(str) {|scan| ... }
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Scans through a string looking for the interoplation-opening <code>#{</code> and, when it&#8217;s found, yields the scanner to the calling code so it can handle it properly.</p>

<p>The scanner will have any backslashes immediately in front of the <code>#{</code> as the second capture group (<code>scan[2]</code>), and the text prior to that as the first (<code>scan[1]</code>).</p>

  </div>
</div>
<div class="tags">
  <h3>Yield Parameters:</h3>
<ul class="yieldparam">
  
    <li>
      
        <span class='type'>(<tt>StringScanner</tt>)</span>
      
      
        <span class='name'>scan</span>
      
      
      
        &mdash;
        The scanner scanning through the string
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        The text remaining in the scanner after all <code>#{</code>s have been processed
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


16
17
18
19
20</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/shared.rb', line 16</span>

def handle_interpolation(str)
  scan = Sass::Util::MultibyteStringScanner.new(str)
  yield scan while scan.scan(/(.*?)(\\*)\#\{/m)
  scan.rest
end</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="human_indentation-instance_method">
  
    - (<tt>String</tt>) <strong>human_indentation</strong>(indentation, was = false) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Formats a string for use in error messages about indentation.</p>

  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
        <span class='name'>indentation</span>
      
      
      
        &mdash;
        The string used for indentation
      
    </li>
  
    <li>
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
        <span class='name'>was</span>
      
      
        <em class="default">(defaults to: <tt>false</tt>)</em>
      
      
        &mdash;
        Whether or not to add <code>&quot;was&quot;</code> or <code>&quot;were&quot;</code> (depending on how many characters were in <code>indentation</code>)
      
    </li>
  
</ul>
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
      
        &mdash;
        The name of the indentation (e.g. <code>&quot;12 spaces&quot;</code>, <code>&quot;1 tab&quot;</code>)
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File '/var/www/sass-pages/.sass/lib/sass/shared.rb', line 57</span>

def human_indentation(indentation, was = false)
  if !indentation.include?(?\t)
    noun = 'space'
  elsif !indentation.include?(?\s)
    noun = 'tab'
  else
    return indentation.inspect + (was ? ' was' : '')
  end

  singular = indentation.length == 1
  if was
    was = singular ? ' was' : ' were'
  else
    was = ''
  end

  "#{indentation.length} #{noun}#{'s' unless singular}#{was}"
end</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Fri Mar  8 20:33:59 2013 by 
  <a href="javascript:if(confirm(%27http://yardoc.org/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?%27))window.location=%27http://yardoc.org/%27" tppabs="http://yardoc.org/" title="Yay! A Ruby Documentation Tool">yard</a>
  0.5.3 (ruby-1.8.7).
</div>


  <script type="text/javascript">
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  </script>
  <script type="text/javascript">
  try {
  var pageTracker = _gat._getTracker("UA-535380-8");
  pageTracker._trackPageview();
  } catch(err) {}</script>


  </body>
</html>